What does a call to 'this->template [somename]' do?

Here is an example where this->template is required. It doesn't really match the OP's example though.

Up vote 5 down vote favorite 2 share g+ share fb share tw.

I've searched for this question and I can't find anything on it. Is there a better way to query something like this in Google or can anyone provide a link or links or a fairly detailed explanation? Thanks!

EDIT: Here's an example template struct Vector { public: Vector() { this->template operator=(0); } // ... template typename boost::enable_if, Vector& >::type operator=(Vector const & other) { typename Vector::ConstIterator j = other.begin(); for (Iterator I = begin(); I! = end(); ++i, ++j) (*i) = (*j); return *this; } }; This example is from the ndarray project on Google Code and is not my own code. C++ templates link|improve this question edited Apr 4 '11 at 0:54Xeo32.1k455109 asked Apr 3 '11 at 23:57cpcloud22819.

Please provide some code examples, your question is rather vague. – Mike Bantegui Apr 3 '11 at 23:59 Unless he had a class which had a data member called template, but that would just be a silly thing to do. – Mike Bantegui Apr 4 '11 at 0:07 4 This is not a "basic" aspect of C++.

– cpcloud Apr 4 '11 at 0:07 1 I have to say, that is some extremely weird syntax. – Mike Bantegui Apr 4 '11 at 0:17 1 @Apprentice Queue: No need to be condescending here. I simply had never come across this syntax before and was wondering how such code behaves.

"this->template" is not something that is addressed when one learns classes in C++. – cpcloud Apr 4 '11 at 0:28.

Here is an example where this->template is required. It doesn't really match the OP's example though: #include template struct X { template void alloc() {std::cout ()\n";} }; template struct Y : public X { void test() { this->template alloc(); } }; int main() { Y y; y.test(); } In this example the this is needed because otherwise alloc would not be looked up in the base class because the base class is dependent on the template parameter T. The template is needed because otherwise the " Names/4).

How mean, didn't get notified of your answer. :) +1 for example + standard reference. – Xeo Apr 4 '11 at 0:24.

Howard's answer is great, as always, but here's some further reading material for you if you like: What is the ->template, . Template and ::template syntax about?

Nice! Thanks. – cpcloud Apr 4 '11 at 18:23.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions